/**
 * 
 */
package com.istart.tika.content;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import org.apache.tika.Tika;
import org.apache.tika.exception.TikaException;
import org.junit.Test;

/**
 * @author 谢进军
 *
 */
public class TikaExtraction {
	private final static String filepath = "src/main/resources/com/istart/tika/tika.txt";
	/**
	 * @param args
	 * @throws TikaException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException, TikaException {
		File file = new File(filepath);
		Tika tika = new Tika();
		String filecontent = tika.parseToString(file);
		System.out.println("Extracted Content:" + filecontent);
	}
	
	@Test public void parseToStringExample() throws IOException, TikaException{
		Tika tika = new Tika();
//		InputStream stream = TikaExtraction.class.getResourceAsStream("tika.txt");
		InputStream stream = TikaExtraction.class.getResourceAsStream("/com/istart/tika/content/tika.txt");
		String filecontent = tika.parseToString(stream);
		System.out.println(filecontent);
	}

}
